package com.kinghunt.misp.common.enums.userx;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 性别枚举
 *
 * @author jiangtao
 * @date 2020-01-30 20:56.
 */
public enum GenderEnum {
    /**
     * 性别
     */
    FEMALE(0, "女"),
    MALE(1, "男"),
    OTHER(2, "其他");

    @Getter
    private Integer value;
    @Getter
    private String desc;

    GenderEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private final static Map<Integer, GenderEnum> map = new HashMap<>(8);
    static {
        for (GenderEnum e : GenderEnum.values()) {
            map.put(e.getValue(), e);
        }
    }

    public static GenderEnum getByType(Integer value) {
        if (Objects.isNull(value)) {
            return null;
        }
        return map.get(value);
    }
}
